var app = new Vue({
  el: "#player",
  data: {
    query: "",
    musicList: [],
    musicId: "",
    musicCover: "",
    isPlaying: false,
    mvUrl: "",
    isShow: false,
  },
  methods: {
    // 搜素歌曲并显示在列表中
    searchMusic: function () {
      var that = this;
      axios.get("https://autumnfish.cn/search?keywords=" + this.query).then(
        function (response) {
          that.musicList = response.data.result.songs;
          console.log(response);
        },
        function (err) {}
      );
    },
    playMusic: function (musicId) {
      var that = this;
      //   修改播放歌曲的地址
      axios.get("https://autumnfish.cn/song/url?id=" + musicId).then(
        function (response) {
          that.musicUrl = response.data.data[0].url;
        },
        function (err) {}
      );
      //   歌曲封面修改
      axios.get("https://autumnfish.cn/song/detail?ids=" + musicId).then(
        function (response) {
          that.musicCover = response.data.songs[0].al.picUrl;
        },
        function (err) {}
      );
      //   歌曲评论修改
      axios.get("https://autumnfish.cn/comment/hot?type=0&id=" + musicId).then(
        function (response) {
          that.hotComments = response.data.hotComments;
        },
        function (err) {}
      );
    },
    //   歌曲播放
    play: function () {
      this.isPlaying = true;
    },
    //   歌曲暂停
    pause: function () {
      this.isPlaying = false;
    },
    //   歌曲mv播放
    playMV: function (mvid) {
      var that = this;
      axios.get("https://autumnfish.cn/mv/url?id=" + mvid).then(
        function (response) {
          that.isShow = true;
          that.mvUrl = response.data.data.url;
        },
        function (err) {}
      );
    },
    //   mv界面隐藏
    hide: function () {
      this.isShow = false;
    },
  },
});
